home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 May / EnigmA AMIGA RUN 18 (1997)(G.R. Edizioni)(IT)[!][issue 1997-05][EAR-CD II].iso / softwareupdate / system / amigados / amigadoslibrary / info.c < prev    next >
C/C++ Source or Header  |  1996-10-10  |  2KB  |  67 lines

  1. /* Info.c   V1.0   93-09-27                        */
  2. /* ROM library: "dos.library/Info", (All versions) */
  3. /* Copyright 1993, Anders Bjerin, Amiga C Club     */
  4.  
  5. #include <dos/dos.h>
  6. #include <exec/memory.h>
  7.  
  8. #include <clib/dos_protos.h>
  9. #include <clib/exec_protos.h>
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12.  
  13. UBYTE *version = "$VER: Info 1.0";
  14.  
  15. int main( int argc, char *argv[] );
  16. int main( int argc, char *argv[] )
  17. {
  18.   BPTR my_lock;
  19.   struct InfoData *my_info_data;
  20.   LONG ok;
  21.  
  22.  
  23.   /* Allocate an InfoData structure: */
  24.   my_info_data = (struct InfoData *)
  25.     AllocMem( sizeof( struct InfoData ), MEMF_ANY );
  26.   if( !my_info_data )
  27.   {
  28.     printf( "Could not allocate enough memory!\n" );
  29.     exit( 20 );
  30.   }
  31.  
  32.   /* Lock the disk: */
  33.   my_lock = Lock( "df0:", SHARED_LOCK );
  34.   if( !my_lock )
  35.   {
  36.     printf( "Could not lock the disk!\n" );
  37.     FreeMem( my_info_data, sizeof( struct InfoData ) );
  38.     exit( 21 );
  39.   }
  40.  
  41.   /* Examine the disk: */
  42.   ok = Info( my_lock, my_info_data );
  43.   if( !ok )
  44.   {
  45.     printf( "Could not examine the disk!\n" );
  46.     UnLock( my_lock );
  47.     FreeMem( (APTR) my_info_data, sizeof( struct InfoData ) );
  48.     exit( 22 );
  49.   }
  50.   
  51.   /* The unit number: */
  52.   printf( "Disk unit number: %d\n", my_info_data->id_UnitNumber );
  53.  
  54.   /* Print some info about the disk: */
  55.   if( my_info_data->id_DiskState == ID_WRITE_PROTECTED )
  56.     printf( "The disk is Write Protected!\n" );
  57.   if( my_info_data->id_DiskState == ID_VALIDATING )
  58.     printf( "The disk is being validated!\n" );
  59.   if( my_info_data->id_DiskState == ID_VALIDATED )
  60.     printf( "The disk is Not (Write) Protected!\n" );
  61.  
  62.   UnLock( my_lock );
  63.   FreeMem( my_info_data, sizeof( struct InfoData ) );
  64.   exit( 0 );
  65. }
  66.  
  67.